<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
<%@ Import Namespace="CSI.Directory.Core.Model"%>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	FreeListing
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<div class="full-content">
    <h2>Free Listing</h2>
    <a href="/Register/Package">Upgrade your account</a>
    <br /><br />
    <form name="listingform" method="post" action="/Directory/AddFreeListing" onsubmit="return validate()" enctype="multipart/form-data">
        <table cellspacing="0" cellpadding="15" border="0" class="datatable">
            <tbody>
                <tr>
                    <td colspan="2" class="tabletitle">
                        General Information
                    </td>
                </tr>
                <tr>
                    <td class="wrap">
                        Company:
                    </td>
                    <td class="dataentry">
                        <input type="text" size="60" value="" name="title" /><span style="color:red">*</span>
                        
                    </td>
                </tr>
             <tr>
                    <td class="wrap">
                        Contact Name:
                    </td>
                    <td class="dataentry">
                        <input type="text" maxlength="100" value="" name="contact" /><span style="color:red">*</span>
                        
                    </td>
                </tr>
                <tr>
                    <td class="wrap">
                        Phone:
                    </td>
                    <td class="dataentry">
                        <input type="text" maxlength="100" value="" name="phone" /><span style="color:red">*</span>
                        
                    </td>
                </tr>
    			
                
            <tr>
                 <td colspan="2" class="tabletitle">
                    Listing Categories
                </td>
            </tr>
            <tr>
                <td>Category</td>
                <td class="dataentry">
                    <select name="category1">
                        <option value="">Select a Category</option>
                        <%foreach (var c in ((IList<Category>)ViewData["Categories"]).Where(t => t.ParentId == 0))
                         {%>
                             <option value="<%=c.Id %>"><%=c.Name%></option>
                              <%foreach (var s in ((IList<Category>)ViewData["Categories"]).Where(t => t.ParentId == c.Id))
                         {%>
                             <option value="<%=s.Id %>">---<%=s.Name%></option>
                             
                         <% }%> 
                        <% }%> 
                        
                    </select>	         
	            </td>
            </tr>
            <tr>
            <td>County</td>
            <td class="dataentry">
            
            
		    
		    <select name="county1" class="dropdownlist required"> 
			<option selected="true" value="">Select a County</option> 
			<%foreach (var c in (IList<County>)ViewData["Counties"]){%>
                 <option value="<%=c.Id %>"><%=c.Name%></option>                            
                             
            <% }%> 
		    </select> 
		    
		    <br /><br />

		
            <input type="hidden" value="<%=((User)ViewData["User"]).Id %>" name="userid" />
		    </td>
		
            </tr>
          </tbody>
        </table>
    <div id="error" style="color:red"></div>
    <input type="submit" value="Submit" />
    </form>
</div>
<script type="text/javascript">
           
      
      function validate()
      {
        $("#error").html("<ul></ul>");
        
       
        if(document.listingform.title.value.length < 2 || document.listingform.title.value == " ")
        {
            $("#error ul").append("<li>Please add a company name.</li>");
            return false;
        }
        if (document.listingform.contact.value.length < 2 || document.listingform.title.value == " ") {
            $("#error ul").append("<li>Please add a contact name.</li>");
            return false;
        }
       
        if(document.listingform.category1.value.length == "" || document.listingform.subcategory1.value == "")
        {
            $("#error ul").append("<li>Please select a category.</li>");
            return false;
        }
        
        
        if (document.listingform.county1.value == "") {
            $("#error ul").append("<li>Please select a county.</li>");
            return false;
        }
        
        return true;
        
      }
      
    </script>

</asp:Content>
